package com.cglib;

import org.objectweb.asm.*;


/**
 * @author fanxiao  2022/3/7
 * @since 1.0.0
 */
public class ClassPrinter extends ClassVisitor {


	public ClassPrinter() {
		super(Opcodes.ASM9);
	}

	@Override
	public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
    	System.out.println(name + " extends " + superName + " {");
	}

	@Override
	public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
		System.out.println("anno descriptor: " + descriptor);
		return new AnnotationPrinterVisitor();
	}

	@Override
	public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
    	System.out.println("name: " + name + ",descriptor: " + descriptor + ",signature: " + signature + ",value: " + value);
    	return null;
	}

	@Override
	public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
		System.out.println("name: " + name + ",descriptor: " + descriptor + ",signature: " + signature);
		return null;
	}

	@Override
	public void visitEnd() {
    	System.out.println("}");
	}
}